package com.example.wheresmystuff2;

import java.util.ArrayList;
import java.util.Date;
import java.util.Map;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.content.Intent;
import android.widget.TextView;
import android.widget.Toast;

/**
 * This is the Item Page activity that gives you the information on the item
 * @author Team 26
 */
public class ItemPage extends Activity {

	Database db;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_item_page);
		db = new Database(this);
		db.open();
		
		Intent intent = getIntent();
		String itemName = intent.getExtras().getString("itemName");
		
		//get map
		ArrayList<Object> itemInfoArray = db.getItemRowAsArray(itemName);
		//set name
		TextView name = (TextView) findViewById(R.id.item_name_info);
		name.setText(" "+itemName);
		//set type
		TextView type = (TextView) findViewById(R.id.item_type_info);
		type.setText(" "+itemInfoArray.get(5));
		//set location
		TextView location = (TextView) findViewById(R.id.item_location_info);
		location.setText(" "+itemInfoArray.get(2));
		//set description
		TextView description = (TextView) findViewById(R.id.item_description_info);
		description.setText(" "+itemInfoArray.get(1));
		//set reward
		TextView reward = (TextView) findViewById(R.id.item_reward_info);
		reward.setText(" "+itemInfoArray.get(7));
		//set date
		TextView date = (TextView) findViewById(R.id.item_date_info);
		date.setText(" "+itemInfoArray.get(6));
		//set date
		TextView category = (TextView) findViewById(R.id.item_category_text);
		category.setText(" "+itemInfoArray.get(4));
		//set date
		TextView status = (TextView) findViewById(R.id.item_status_text);
		status.setText(" "+itemInfoArray.get(3));
		
		db.close();
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.item_page, menu);
		return true;
	}

}
